#ifndef __TCPCONNECTION_H__
#define __TCPCONNECTION_H__

#include "Socket.h"
#include "SocketIO.h"
#include "InetAddress.h"
#include "Epoll.h"
#include <functional>

enum SockType
{
    esock_invalid = 0,
    esock_listen = 1,
    esock_connecting = 2,
    esock_connected = 3,
};

typedef std::function<void ()> TcpConnectionCb;
class TcpConnection
{
public:

    TcpConnection(int peerfd, InetAddress addr, Epoll &epoll);
    ~TcpConnection();

    void sendTcpData(string &s);
    void sendTcpQueue();
    void sendAndClose(char *buffer, uint16_t len);
    void shutdown();
	void readTcpData();
	queue<string> &getReadQueue();

    void printConnInfo();
    
    SockType socktype_;
    Socket sockfd_;
    InetAddress peerAddr_;
	uint32_t events;
    Epoll &epoll_;

private:
    SocketIO data_;
	int recvSize_;
};

#endif
